﻿using System.Security;
using System.Security.Principal;

namespace SymbolicLinkManageCore.Library.UsersAndPermissions
{
    public class UsersAndPermissionsUtilityTools
    {
        public static bool? OsCurrentUserIsAdministrator()
        {
            try
            {
                var windowsIdentity = WindowsIdentity.GetCurrent();
                var windowsPrincipal = new WindowsPrincipal(windowsIdentity);

                return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
            }
            catch (SecurityException) { return null; }
        }
    }
}
